<!--职业健康统计分析-->
<template>
    <Layout class="menu-left">
        <Form ref="queryForm" :model="dataToQuery" style="margin-top: 10px;" :label-width="120">
            <Row v-show="!switchFlag" class="query-form" >
                <Col span="8">
                <FormItem label="企业名称：" prop="order">
                    <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyId' :orgTree="true"
                                  :currentOrgId="dataToQuery.companyId"
                                  :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                </FormItem>
                </Col>
                <Col span="8">
                <FormItem label='年度：' prop='year'>
                    <DatePicker class="query-form-el" placeholder="请选择年度" v-model='dataToQuery.yearDate' type="year"></DatePicker>
                </FormItem>
                </Col>
                <Col span="8">
                <Button @click="reset" class="ivu-btn-reset">重置</Button>
                <Button type="primary" class="ivu-btn-query" icon="md-search"  @click="query">查询</Button>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                <FormItem label="企业名称：" prop="belongOrgId">
                    <cascader-dom class="query-form-el" ref='queryOrgCascader1' @setOrgInfo='setQueryCompanyId' :orgTree="true"
                                  :currentOrgId="dataToQuery.companyId" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                </FormItem>
                </Col>
                <Col span="8">
                <FormItem label='年度：' prop='year'>
                    <DatePicker class="query-form-el" placeholder="请选择年度" v-model='dataToQuery.yearDate' type="year"></DatePicker>
                </FormItem>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                </Col>
            </Row>
        </Form>
        <div class="table-box">
            <Table ref='table' :height="tableHeight"  no-data-text="没有查询到相关数据!"  :loading='pageStatus.loading'
                   :row-class-name="(row,index)=>(index===0)?'table-summary-row':''"
                   border :columns="columns1"  :data="dataTable" >
            </Table>
        </div>
       <!-- <Row style="margin-right:10px;">
            <Col span="24" >
            <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </Col>
        </Row>-->
    </Layout>
</template>
<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        name: "healthSafeStatistics",
        components:{
            cascaderDom
        },
        data() {
            return{
                ...this.createCommonDataField(),
                columns1: [
                    { key:'companyName',title: '单位名称',  align: 'center',fixed: 'left', width:300},
                    {key: 'victimNum', title: '职业病危害接触人数', align: 'center', minWidth: 150},
                    {key: 'physicalExamNum', title: '在岗体检人数', align: 'center', minWidth: 150},
                ],
                tableHeight:10,
                // 切换标签
                modaleShow:1,
                // api
                queryUrl:Api.reportSafeRptHealth,

            }
        },
        mounted(){
            this.setTableHeight()
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            query() {
                this.dataToQuery.twoLevelOrgId = this.currentUser.twoLevelOrgId?this.currentUser.twoLevelOrgId:undefined
                if(!this.dataToQuery.yearDate) {
                    this.dataToQuery.yearDate = new Date();
                }
                if(this.dataToQuery.yearDate) {
                    this.dataToQuery.year = this.dataToQuery.yearDate.getFullYear();
                }
                if(!this.dataToQuery.companyId) {
                    this.dataToQuery.companyId = undefined
                }
                this.queryAjax();
            },
            lowerStep(name) {
                this.modaleShow = name
                if (name == 1) {
                    this.queryUrl = Api.reportEnRptInvestment
                }else{
                    this.queryUrl = Api.reportEnRptInvestmentPlan
                }
                this.setTableHeight()
                this.query();

            }
        }
    }
</script>
<style scoped>
    /deep/ .table-box .ivu-table-header th{position: static;border: 1px solid #ddd;}
</style>
